$(function () {
    webSocket();
    // 设置Header日期
    $('.date').html(new Date().format("yyyy-MM-dd"));
    // 设置天气
    var weatherEl = $('.weather');
    publicAjax(basePath + 'screen/queryWeather', 'get', {}, function (data) {
        if (data.ret === 500) {
            var data = JSON.parse(data.data || '');
            weatherEl.find('.weather-img').html(getWeatherImg(data.data.forecast[0].type));
            weatherEl.find('.weather-info').html(fixStr(data.cityInfo.city) + '    ' + data.data.forecast[0].low.match(/\d+(\.\d+)?/g)[0] + '~' + data.data.forecast[0].high.match(/\d+(\.\d+)?/g)[0] + '℃    ' + data.data.forecast[0].type);
        } else {
            flavrShowByTime(data.msg, null, 'error', false);
        }
    });
    /* 获取天气 */
    function getWeatherImg(weather) {
        var name = '';
        if (weather.indexOf('沙') !== -1) {
            name = 'sand';
        } else if (weather.indexOf('雪') !== -1) {
            name = 'snow';
        } else if (weather.indexOf('雷') !== -1) {
            name = 'thunder';
        } else if (weather.indexOf('雨') !== -1) {
            name = 'rain';
        } else if (weather.indexOf('雾') !== -1) {
            name = 'flog';
        } else if (weather.indexOf('阴') !== -1) {
            name = 'overcast';
        } else if (weather.indexOf('多云') !== -1) {
            name = 'cloudy';
        } else {
            name = 'sun';
        }
        return '<img src="' + basePath + '/images/weather/' + name + '.png">';
    }

    /* 初始化地图图表 */
    window.chartMap = echarts.init($('.map')[0]);
    window.optionMap = {
        grid: {
            top: 0,
            right: 0,
            bottom: 0,
            left: 0
        },
        tooltip: {
            trigger: 'item',
            formatter: function (params) {
                return params.name + '<br>' +
                    '设备数量：' + params.value[3] + '台<br>' +
                    '设备金额：' + fix2(params.value[2]/1000000) + '万元<br>' +
                    '当年维修：' + params.value[4] + '次<br>' +
                    '当年保养：' + params.value[5] + '次<br>';
            }
        },
        geo: {
            show: true,
            map: 'china',
            label: {
                normal: {
                    show: true,
                    color: '#fff'
                },
                emphasis: {
                    show: false
                }
            },
            aspectScale: 0.8,
            zoom: 1.2,
            roam: true,
            itemStyle: {
                normal: {
                    areaColor: '#2e4452',
                    borderColor: '#263240'
                },
                emphasis: {
                    areaColor: '#2B91B7'
                }
            }
        },
        series: [{
            name: 'normal',
            type: 'effectScatter',
            coordinateSystem: 'geo',
            data: [],
            showEffectOn: 'render',
            rippleEffect: {
                brushType: 'stroke'
            },
            hoverAnimation: true,
            label: {
                normal: {
                    formatter: '{b}',
                    position: 'right',
                    show: false
                }
            },
            itemStyle: {
                normal: {
                    color: '#2bfd9a',
                    shadowBlur: 20,
                    shadowColor: '#2bfd9a'
                }
            },
            symbolSize: 20
        }, {
            name: 'repair',
            type: 'effectScatter',
            coordinateSystem: 'geo',
            data: [],
            showEffectOn: 'render',
            rippleEffect: {
                brushType: 'stroke'
            },
            hoverAnimation: true,
            label: {
                normal: {
                    formatter: '{b}',
                    position: 'right',
                    show: false
                }
            },
            itemStyle: {
                normal: {
                    color: '#F62020',
                    shadowBlur: 20,
                    shadowColor: '#F62020'
                }
            },
            symbolSize: 20
        }, {
            name: 'upkeep',
            type: 'effectScatter',
            coordinateSystem: 'geo',
            data: [],
            showEffectOn: 'render',
            rippleEffect: {
                brushType: 'stroke'
            },
            hoverAnimation: true,
            label: {
                normal: {
                    formatter: '{b}',
                    position: 'right',
                    show: false
                }
            },
            itemStyle: {
                normal: {
                    color: '#00C5E4',
                    shadowBlur: 20,
                    shadowColor: '#00C5E4'
                }
            },
            symbolSize: 20
        }]
    };
    // $('.map').on('click',function () {
    //     setGeoChart(screens, 'china');
    // })
    chartMap.on('click',function (params) {
        if(params.componentType === 'series'){
            var userName = params.value[8];
            var passWord = params.value[9];
            if(userName == null || passWord == null ){
                flavrShowByTime('该医院下没有账号或者密码',null,'danger',false);
                return
            }else {
                var userName1 = Base64.encode(userName);
                var passWord1 = Base64.encode(passWord);
                var loginAddress = $("#loginAddress").val();
                window.open('html/loginIndex.html?UN/'+userName1+'&PW/'+passWord1+'&loginAddress/'+loginAddress)
            }
        } else if (params.componentType === 'geo') {
            if (geoMap[params.name]) {
                var newScreens = screens.filter(function (val,key) {
                    return !val.province.indexOf(params.name) || !val.city.indexOf(params.name)
                })
                setGeoChart(newScreens, geoMap[params.name]);
            } else {
                setGeoChart(screens, 'gdgx');
            }
        }
    });
    var geoMap = {
        '安徽': 'province/anhui',
        '澳门': 'province/aomen',
        '北京': 'province/beijing',
        '重庆': 'province/chongqing',
        '福建': 'province/fujian',
        '甘肃': 'province/gansu',
        '广东': 'province/guangdong',
        '广西': 'province/guangxi',
        '贵州': 'province/guizhou',
        '海南': 'province/hainan',
        '河北': 'province/hebei',
        '黑龙江': 'province/heilongjiang',
        '河南': 'province/henan',
        '湖北': 'province/hubei',
        '湖南': 'province/hunan',
        '江苏': 'province/jiangsu',
        '江西': 'province/jiangxi',
        '吉林': 'province/jilin',
        '辽宁': 'province/liaoning',
        '内蒙古': 'province/neimenggu',
        '宁夏': 'province/ningxia',
        '青海': 'province/qinghai',
        '山东': 'province/shandong',
        '上海': 'province/shanghai',
        '山西': 'province/shanxi',
        '陕西': 'province/shanxi1',
        '四川': 'province/sichuan',
        '台湾': 'province/taiwan',
        '天津': 'province/tianjin',
        '香港': 'province/xianggang',
        '新疆': 'province/xinjiang',
        '西藏': 'province/xizang',
        '云南': 'province/yunnan',
        '浙江': 'province/zhejiang',
        "北京市": "citys/110100",
        "天津市": "citys/120100",
        "上海市": "citys/310100",
        "重庆市": "citys/500100",
        "崇明县": "citys/310200",
        "湖北省直辖县市": "citys/429000",
        "铜仁市": "citys/522200",
        "毕节市": "citys/522400",
        "石家庄市": "citys/130100",
        "唐山市": "citys/130200",
        "秦皇岛市": "citys/130300",
        "邯郸市": "citys/130400",
        "邢台市": "citys/130500",
        "保定市": "citys/130600",
        "张家口市": "citys/130700",
        "承德市": "citys/130800",
        "沧州市": "citys/130900",
        "廊坊市": "citys/131000",
        "衡水市": "citys/131100",
        "太原市": "citys/140100",
        "大同市": "citys/140200",
        "阳泉市": "citys/140300",
        "长治市": "citys/140400",
        "晋城市": "citys/140500",
        "朔州市": "citys/140600",
        "晋中市": "citys/140700",
        "运城市": "citys/140800",
        "忻州市": "citys/140900",
        "临汾市": "citys/141000",
        "吕梁市": "citys/141100",
        "呼和浩特市": "citys/150100",
        "包头市": "citys/150200",
        "乌海市": "citys/150300",
        "赤峰市": "citys/150400",
        "通辽市": "citys/150500",
        "鄂尔多斯市": "citys/150600",
        "呼伦贝尔市": "citys/150700",
        "巴彦淖尔市": "citys/150800",
        "乌兰察布市": "citys/150900",
        "兴安盟": "citys/152200",
        "锡林郭勒盟": "citys/152500",
        "阿拉善盟": "citys/152900",
        "沈阳市": "citys/210100",
        "大连市": "citys/210200",
        "鞍山市": "citys/210300",
        "抚顺市": "citys/210400",
        "本溪市": "citys/210500",
        "丹东市": "citys/210600",
        "锦州市": "citys/210700",
        "营口市": "citys/210800",
        "阜新市": "citys/210900",
        "辽阳市": "citys/211000",
        "盘锦市": "citys/211100",
        "铁岭市": "citys/211200",
        "朝阳市": "citys/211300",
        "葫芦岛市": "citys/211400",
        "长春市": "citys/220100",
        "吉林市": "citys/220200",
        "四平市": "citys/220300",
        "辽源市": "citys/220400",
        "通化市": "citys/220500",
        "白山市": "citys/220600",
        "松原市": "citys/220700",
        "白城市": "citys/220800",
        "延边朝鲜族自治州": "citys/222400",
        "哈尔滨市": "citys/230100",
        "齐齐哈尔市": "citys/230200",
        "鸡西市": "citys/230300",
        "鹤岗市": "citys/230400",
        "双鸭山市": "citys/230500",
        "大庆市": "citys/230600",
        "伊春市": "citys/230700",
        "佳木斯市": "citys/230800",
        "七台河市": "citys/230900",
        "牡丹江市": "citys/231000",
        "黑河市": "citys/231100",
        "绥化市": "citys/231200",
        "大兴安岭地区": "citys/232700",
        "南京市": "citys/320100",
        "无锡市": "citys/320200",
        "徐州市": "citys/320300",
        "常州市": "citys/320400",
        "苏州市": "citys/320500",
        "南通市": "citys/320600",
        "连云港市": "citys/320700",
        "淮安市": "citys/320800",
        "盐城市": "citys/320900",
        "扬州市": "citys/321000",
        "镇江市": "citys/321100",
        "泰州市": "citys/321200",
        "宿迁市": "citys/321300",
        "杭州市": "citys/330100",
        "宁波市": "citys/330200",
        "温州市": "citys/330300",
        "嘉兴市": "citys/330400",
        "湖州市": "citys/330500",
        "绍兴市": "citys/330600",
        "金华市": "citys/330700",
        "衢州市": "citys/330800",
        "舟山市": "citys/330900",
        "台州市": "citys/331000",
        "丽水市": "citys/331100",
        "合肥市": "citys/340100",
        "芜湖市": "citys/340200",
        "蚌埠市": "citys/340300",
        "淮南市": "citys/340400",
        "马鞍山市": "citys/340500",
        "淮北市": "citys/340600",
        "铜陵市": "citys/340700",
        "安庆市": "citys/340800",
        "黄山市": "citys/341000",
        "滁州市": "citys/341100",
        "阜阳市": "citys/341200",
        "宿州市": "citys/341300",
        "六安市": "citys/341500",
        "亳州市": "citys/341600",
        "池州市": "citys/341700",
        "宣城市": "citys/341800",
        "福州市": "citys/350100",
        "厦门市": "citys/350200",
        "莆田市": "citys/350300",
        "三明市": "citys/350400",
        "泉州市": "citys/350500",
        "漳州市": "citys/350600",
        "南平市": "citys/350700",
        "龙岩市": "citys/350800",
        "宁德市": "citys/350900",
        "南昌市": "citys/360100",
        "景德镇市": "citys/360200",
        "萍乡市": "citys/360300",
        "九江市": "citys/360400",
        "新余市": "citys/360500",
        "鹰潭市": "citys/360600",
        "赣州市": "citys/360700",
        "吉安市": "citys/360800",
        "宜春市": "citys/360900",
        "抚州市": "citys/361000",
        "上饶市": "citys/361100",
        "济南市": "citys/370100",
        "青岛市": "citys/370200",
        "淄博市": "citys/370300",
        "枣庄市": "citys/370400",
        "东营市": "citys/370500",
        "烟台市": "citys/370600",
        "潍坊市": "citys/370700",
        "济宁市": "citys/370800",
        "泰安市": "citys/370900",
        "威海市": "citys/371000",
        "日照市": "citys/371100",
        "莱芜市": "citys/371200",
        "临沂市": "citys/371300",
        "德州市": "citys/371400",
        "聊城市": "citys/371500",
        "滨州市": "citys/371600",
        "菏泽市": "citys/371700",
        "郑州市": "citys/410100",
        "开封市": "citys/410200",
        "洛阳市": "citys/410300",
        "平顶山市": "citys/410400",
        "安阳市": "citys/410500",
        "鹤壁市": "citys/410600",
        "新乡市": "citys/410700",
        "焦作市": "citys/410800",
        "濮阳市": "citys/410900",
        "许昌市": "citys/411000",
        "漯河市": "citys/411100",
        "三门峡市": "citys/411200",
        "南阳市": "citys/411300",
        "商丘市": "citys/411400",
        "信阳市": "citys/411500",
        "周口市": "citys/411600",
        "驻马店市": "citys/411700",
        "省直辖县级行政区划": "citys/469000",
        "武汉市": "citys/420100",
        "黄石市": "citys/420200",
        "十堰市": "citys/420300",
        "宜昌市": "citys/420500",
        "襄阳市": "citys/420600",
        "鄂州市": "citys/420700",
        "荆门市": "citys/420800",
        "孝感市": "citys/420900",
        "荆州市": "citys/421000",
        "黄冈市": "citys/421100",
        "咸宁市": "citys/421200",
        "随州市": "citys/421300",
        "恩施土家族苗族自治州": "citys/422800",
        "长沙市": "citys/430100",
        "株洲市": "citys/430200",
        "湘潭市": "citys/430300",
        "衡阳市": "citys/430400",
        "邵阳市": "citys/430500",
        "岳阳市": "citys/430600",
        "常德市": "citys/430700",
        "张家界市": "citys/430800",
        "益阳市": "citys/430900",
        "郴州市": "citys/431000",
        "永州市": "citys/431100",
        "怀化市": "citys/431200",
        "娄底市": "citys/431300",
        "湘西土家族苗族自治州": "citys/433100",
        "广州市": "citys/440100",
        "韶关市": "citys/440200",
        "深圳市": "citys/440300",
        "珠海市": "citys/440400",
        "汕头市": "citys/440500",
        "佛山市": "citys/440600",
        "江门市": "citys/440700",
        "湛江市": "citys/440800",
        "茂名市": "citys/440900",
        "肇庆市": "citys/441200",
        "惠州市": "citys/441300",
        "梅州市": "citys/441400",
        "汕尾市": "citys/441500",
        "河源市": "citys/441600",
        "阳江市": "citys/441700",
        "清远市": "citys/441800",
        "东莞市": "citys/441900",
        "中山市": "citys/442000",
        "潮州市": "citys/445100",
        "揭阳市": "citys/445200",
        "云浮市": "citys/445300",
        "南宁市": "citys/450100",
        "柳州市": "citys/450200",
        "桂林市": "citys/450300",
        "梧州市": "citys/450400",
        "北海市": "citys/450500",
        "防城港市": "citys/450600",
        "钦州市": "citys/450700",
        "贵港市": "citys/450800",
        "玉林市": "citys/450900",
        "百色市": "citys/451000",
        "贺州市": "citys/451100",
        "河池市": "citys/451200",
        "来宾市": "citys/451300",
        "崇左市": "citys/451400",
        "海口市": "citys/460100",
        "三亚市": "citys/460200",
        "三沙市": "citys/460300",
        "成都市": "citys/510100",
        "自贡市": "citys/510300",
        "攀枝花市": "citys/510400",
        "泸州市": "citys/510500",
        "德阳市": "citys/510600",
        "绵阳市": "citys/510700",
        "广元市": "citys/510800",
        "遂宁市": "citys/510900",
        "内江市": "citys/511000",
        "乐山市": "citys/511100",
        "南充市": "citys/511300",
        "眉山市": "citys/511400",
        "宜宾市": "citys/511500",
        "广安市": "citys/511600",
        "达州市": "citys/511700",
        "雅安市": "citys/511800",
        "巴中市": "citys/511900",
        "资阳市": "citys/512000",
        "阿坝藏族羌族自治州": "citys/513200",
        "甘孜藏族自治州": "citys/513300",
        "凉山彝族自治州": "citys/513400",
        "贵阳市": "citys/520100",
        "六盘水市": "citys/520200",
        "遵义市": "citys/520300",
        "安顺市": "citys/520400",
        "黔西南布依族苗族自治州": "citys/522300",
        "黔东南苗族侗族自治州": "citys/522600",
        "黔南布依族苗族自治州": "citys/522700",
        "昆明市": "citys/530100",
        "曲靖市": "citys/530300",
        "玉溪市": "citys/530400",
        "保山市": "citys/530500",
        "昭通市": "citys/530600",
        "丽江市": "citys/530700",
        "普洱市": "citys/530800",
        "临沧市": "citys/530900",
        "楚雄彝族自治州": "citys/532300",
        "红河哈尼族彝族自治州": "citys/532500",
        "文山壮族苗族自治州": "citys/532600",
        "西双版纳傣族自治州": "citys/532800",
        "大理白族自治州": "citys/532900",
        "德宏傣族景颇族自治州": "citys/533100",
        "怒江傈僳族自治州": "citys/533300",
        "迪庆藏族自治州": "citys/533400",
        "拉萨市": "citys/540100",
        "昌都地区": "citys/542100",
        "山南地区": "citys/542200",
        "日喀则地区": "citys/542300",
        "那曲地区": "citys/542400",
        "阿里地区": "citys/542500",
        "林芝地区": "citys/542600",
        "西安市": "citys/610100",
        "铜川市": "citys/610200",
        "宝鸡市": "citys/610300",
        "咸阳市": "citys/610400",
        "渭南市": "citys/610500",
        "延安市": "citys/610600",
        "汉中市": "citys/610700",
        "榆林市": "citys/610800",
        "安康市": "citys/610900",
        "商洛市": "citys/611000",
        "兰州市": "citys/620100",
        "嘉峪关市": "citys/620200",
        "金昌市": "citys/620300",
        "白银市": "citys/620400",
        "天水市": "citys/620500",
        "武威市": "citys/620600",
        "张掖市": "citys/620700",
        "平凉市": "citys/620800",
        "酒泉市": "citys/620900",
        "庆阳市": "citys/621000",
        "定西市": "citys/621100",
        "陇南市": "citys/621200",
        "临夏回族自治州": "citys/622900",
        "甘南藏族自治州": "citys/623000",
        "西宁市": "citys/630100",
        "海东地区": "citys/632100",
        "海北藏族自治州": "citys/632200",
        "黄南藏族自治州": "citys/632300",
        "海南藏族自治州": "citys/632500",
        "果洛藏族自治州": "citys/632600",
        "玉树藏族自治州": "citys/632700",
        "海西蒙古族藏族自治州": "citys/632800",
        "银川市": "citys/640100",
        "石嘴山市": "citys/640200",
        "吴忠市": "citys/640300",
        "固原市": "citys/640400",
        "中卫市": "citys/640500",
        "乌鲁木齐市": "citys/650100",
        "克拉玛依市": "citys/650200",
        "吐鲁番地区": "citys/652100",
        "哈密地区": "citys/652200",
        "昌吉回族自治州": "citys/652300",
        "博尔塔拉蒙古自治州": "citys/652700",
        "巴音郭楞蒙古自治州": "citys/652800",
        "阿克苏地区": "citys/652900",
        "克孜勒苏柯尔克孜自治州": "citys/653000",
        "喀什地区": "citys/653100",
        "和田地区": "citys/653200",
        "伊犁哈萨克自治州": "citys/654000",
        "塔城地区": "citys/654200",
        "阿勒泰地区": "citys/654300",
        "自治区直辖县级行政区划": "citys/659000",
        "台湾省": "citys/710000",
        "香港特别行政区": "citys/810100",
        "澳门特别行政区": "citys/820000"
    };

    /* 获取总计数据及地图是数据 */
    var hospitalCount = $('.hospital-count');
    var assetsCount = $('.assets-count');
    var assetsPrice = $('.assets-price');
    var repairCount = $('.repair-count');
    var upkeepCount = $('.upkeep-count');
    publicAjax(basePath + '/screen/queryList', 'post', null, function (data) {
        if (data.ret === 200) {
            numAnimate({
                el: hospitalCount,  // jquery对象
                newNum: data.data.hospitalCount
            });
            numAnimate({
                el: assetsCount,  // jquery对象
                newNum: data.data.assetsCount
            });
            numAnimate({
                el: assetsPrice,  // jquery对象
                newNum: data.data.totalAmount / 1000000,
                fixNum: 2
            });
            numAnimate({
                el: repairCount,  // jquery对象
                newNum: data.data.repairCount
            });
            numAnimate({
                el: upkeepCount,  // jquery对象
                newNum: data.data.upkeepCount
            });

            /* 地图数据 */
            screens = data.data.screens;
            setGeoChart(screens, 'gdgx');
        } else {
            flavrShowByTime(data.msg, null, 'error', false);
        }
    });

    /* 设置Map数据 */
    function setGeoChart (screens, city) {
        $.getJSON(basePath + '/js/index/' + city + '.json', function (geoJson) {
            echarts.registerMap(city, geoJson);
            var data = [];
            var totalAmountArr = [];
            for (var i = 0; i < screens.length; i++) {
                if (screens[i].mapX && screens[i].mapY) {
                    data.push({
                        name: screens[i].hospitalName,
                        /* 经度，纬度，设备金额，设备数量，维修数量，保养数量，医院id，服务商id */
                        value: [screens[i].mapX, screens[i].mapY, fix0(screens[i].totalAmount), screens[i].assetsCount, screens[i].repairCount, screens[i].upkeepCount, screens[i].hospitalId, screens[i].serviceProviderId, screens[i].userName, screens[i].password]
                    });
                    totalAmountArr.push(screens[i].totalAmount);
                }
            }
            optionMap.geo.map = city;
            optionMap.series[0].data = data;
            optionMap.series[0].sampleSize = optionMap.series[1].sampleSize = optionMap.series[2].sampleSize = function (data) {
                var max = totalAmountArr.max(),
                    min = totalAmountArr.min(),
                    range = max - min;
                if (range === 0) return 35;
                return data[2] === 0 ? 20 : (30 * (data[2] - min) / range + 20);
            };
            chartMap.clear();
            chartMap.setOption(optionMap);
            chartMap.resize();
        });
    }

    /* 初始化待处理模态框 */
    var repairList = $('#repair-list');
    var upkeepList = $('#upkeep-list');
    var inspectionList = $('#inspection-list');
    $('#repair-list, #upkeep-list, #inspection-list').each(function () {
        var obj = $(this);
        obj.iziModal({
            title: obj.data().title,
            headerColor: '#88A0B9',
            width: 1000,
            radius: 3,
            zindex: 999,
            history: false,
            fullscreen: true,
            closeOnEscape: true,
            overlayColor: 'rgba(0, 0, 0, 0.4)',
            onOpening: function(){},
            onOpened: function(){},
            onClosing: function(){},
            onClosed: function(){}
        });
    });

    /* 运维管理数据 */
    var contentStr = '';
    // 维修数据
    window.queryRepairList = function () {
        var repairTip = $('.repair-icon').find('.tip');
        publicAjax(basePath + '/screen/queryRepairList', 'post', null, function (data) {
            if (data.ret === 200) {
                numAnimate({
                    el: repairTip,  // jquery对象
                    newNum: data.data.length
                });
                var str = '',
                    list = data.data;
                if (list.length) {
                    for (var i = 0; i < list.length; i++) {
                        str += '<tr data-id="' + list[i].id + '">' +
                            '<td>' + (i + 1) + '</td>' +
                            '<td>' + fixStr(list[i].assetsName) + '</td>' +
                            '<td>' + fixStr(list[i].hospital) + '</td>' +
                            '<td>' + fixStr(list[i].department) + '</td>' +
                            '<td>' + fixStr(list[i].assetsNo) + '</td>' +
                            '<td>' + fixStr(list[i].model) + '</td>' +
                            '<td>' + fixStr(list[i].repairTime) + '</td>' +
                            '<td>' + fixStr(list[i].name) + '</td>' +
                            '</tr>';
                        contentStr += '<li title="' + fixStr(list[i].content) + '" id="msg-' + list[i].id + '">' +
                                '<i class="repair-icon"></i>' +
                                fixStr(list[i].content) +
                            '</li>';
                    }
                    messageBox.html(contentStr);
                    setMessageBox();
                } else {
                    str = '<tr><td class="text-center" colspan="8">暂无数据！</td></tr>';
                }
                repairList.find('tbody').html(str);
            } else {
                flavrShowByTime(data.msg, null, 'error', false);
            }
        });
    };
    queryRepairList();

    function setMessageBox () {
        try {
            message.vTicker('stop');
        } catch (e) {
            console.log(e);
        }
        clearTimeout(timer);
        if (messageBox.height() > message.height()) {
            message.vTicker();
        }
    }
    // 保养数据
    window.queryUpkeepList = function () {
        var upkeepTip = $('.upkeep-icon').find('.tip');
        publicAjax(basePath + '/screen/queryUpkeepList', 'post', null, function (data) {
            if (data.ret === 200) {
                numAnimate({
                    el: upkeepTip,  // jquery对象
                    newNum: data.data.length
                });
                var str = '',
                    list = data.data;
                if (list.length) {
                    for (var i = 0; i < list.length; i++) {
                        str += '<tr data-id="' + list[i].id + '">' +
                            '<td>' + (i + 1) + '</td>' +
                            '<td>' + fixStr(list[i].assetsName) + '</td>' +
                            '<td>' + fixStr(list[i].hospital) + '</td>' +
                            '<td>' + fixStr(list[i].department) + '</td>' +
                            '<td>' + fixStr(list[i].assetsNo) + '</td>' +
                            '<td>' + fixStr(list[i].upkeepDate) + '</td>' +
                            '</tr>';
                        contentStr += '<li title="' + fixStr(list[i].content) + '" id="msg-' + list[i].id + '">' +
                            '<i class="upkeep-icon"></i>' +
                            fixStr(list[i].content) +
                            '</li>';
                    }
                    messageBox.html(contentStr);
                    setMessageBox();
                } else {
                    str = '<tr><td class="text-center" colspan="6">暂无数据！</td></tr>';
                }
                upkeepList.find('tbody').html(str);
            } else {
                flavrShowByTime(data.msg, null, 'error', false);
            }
        });
    };
    queryUpkeepList();

    // 巡检数据
    window.queryInspectionList = function () {
        var inspectionTip = $('.inspection-icon').find('.tip');
        publicAjax(basePath + '/screen/queryInspectionList', 'post', null, function (data) {
            if (data.ret === 200) {
                numAnimate({
                    el: inspectionTip,  // jquery对象
                    newNum: data.data.length
                });
                var str = '',
                    list = data.data;
                if (list.length) {
                    for (var i = 0; i < list.length; i++) {
                        str += '<tr data-id="' + list[i].id + '">' +
                            '<td>' + (i + 1) + '</td>' +
                            '<td>' + fixStr(list[i].assetsName) + '</td>' +
                            '<td>' + fixStr(list[i].hospital) + '</td>' +
                            '<td>' + fixStr(list[i].department) + '</td>' +
                            '<td>' + fixStr(list[i].assetsNo) + '</td>' +
                            '<td>' + fixStr(list[i].dateExpected) + '</td>' +
                            '</tr>';
                        contentStr += '<li title="' + fixStr(list[i].content) + '" id="msg-' + list[i].id + '">' +
                            '<i class="inspection-icon"></i>' +
                            fixStr(list[i].content) +
                            '</li>';
                    }
                    messageBox.html(contentStr);
                    setMessageBox();
                } else {
                    str = '<tr><td class="text-center" colspan="6">暂无数据！</td></tr>';
                }
                inspectionList.find('tbody').html(str);
            } else {
                flavrShowByTime(data.msg, null, 'error', false);
            }
        });
    };
    queryInspectionList();

    $('.repair-icon, .upkeep-icon, .inspection-icon').click(function () {
        var obj = $(this);
        if (obj.hasClass('repair-icon')) {
            repairList.iziModal('open');
        } else if (obj.hasClass('upkeep-icon')) {
            upkeepList.iziModal('open');
        } else if (obj.hasClass('inspection-icon')) {
            inspectionList.iziModal('open');
        }
    });

});